package com.blockchain.console.servlets.user;

import java.sql.Timestamp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blockchain.common.enums.CertificateType;
import com.blockchain.common.enums.IsPass;
import com.blockchain.console.service.user.UserManage;
import com.blockchain.console.service.user.entity.User;
import com.blockchain.console.service.user.query.UserQuery;
import com.blockchain.framework.http.servlet.annotation.Right;
import com.blockchain.framework.service.ServiceSession;
import com.blockchain.framework.service.query.Paging;
import com.blockchain.framework.service.query.PagingResult;
import com.blockchain.util.parser.EnumParser;
import com.blockchain.util.parser.IntegerParser;
import com.blockchain.util.parser.TimestampParser;

@Right(id = "C_USER_LIST", isMenu = true, name = "高级实名认证")
public class UserGjrz extends AbstractUserServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void processGet(HttpServletRequest request, HttpServletResponse response, ServiceSession serviceSession)
			throws Throwable {
		processPost(request, response, serviceSession);
	}

	@Override
	protected void processPost(final HttpServletRequest request, final HttpServletResponse response,
			final ServiceSession serviceSession) throws Throwable {
		UserManage userManage = serviceSession.getService(UserManage.class);
		PagingResult<User> users = userManage.gjsmList(new UserQuery() {
			@Override
			public int getUserId() {
				return IntegerParser.parse(request.getParameter("userid"));
			}

			@Override
			public String getName() {
				return request.getParameter("name");
			}

			@Override
			public String getZjh() {
				return request.getParameter("zjh");
			}

			@Override
			public IsPass getSftgjrz() {
				 return EnumParser.parse(IsPass.class, request.getParameter("sftgjrz"));
			}

			@Override
			public String getSjh() {
				return request.getParameter("sjh");
			}

			@Override
			public Timestamp getCreateTimeStart() {
				return TimestampParser.parse(request.getParameter("start"));
			}

			@Override
			public Timestamp getCreateTimeEnd() {
				return TimestampParser.parse(request.getParameter("end"));
			}

			@Override
			public IsPass getUserState() {
				return EnumParser.parse(IsPass.class, request.getParameter("userState"));
			}

			@Override
			public CertificateType getCertificateType() {
				return null;
			}

			@Override
			public IsPass getSfts() {
				return null;
			}

			@Override
			public int getZbxe() {
				return 0;
			}

		}, new Paging() {

			@Override
			public int getSize() {
				return 10;
			}

			@Override
			public int getCurrentPage() {
				return IntegerParser.parse(request.getParameter(PAGING_CURRENT));
			}
		});
		request.setAttribute("users", users);
		forwardView(request, response, getClass());
	}

}
